package xujoe.SSMDemo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import xujoe.SSMDemo.pojo.Admin;
import xujoe.SSMDemo.service.AdminService;

import javax.annotation.Resource;

@Controller
public class main {

/*
    @Resource
    AdminService adminService;
    @RequestMapping("/")
    @ResponseBody
    public String index() {
        return "hello world";
    }

    @RequestMapping(value = "/admin", method = RequestMethod.POST)
    @ResponseBody
    public int insertUser(Admin admin) {
        return adminService.insertAdmin(admin);

    }

    @RequestMapping(value = "/admin/{id}", method = RequestMethod.GET)
    @ResponseBody
    public Admin getUser(@PathVariable Integer id) {
        return adminService.getAdmin(id);

    }
*/


    @Resource
    public AdminService adminService;

    @RequestMapping(value = "login.do")
    public String Login(String user, String password) {
        boolean flag =adminService.Login(user,password);
        return  flag?"1.jsp":"index.jsp";
    }


    @RequestMapping(value = "/admin/{id}", method = RequestMethod.GET)
    @ResponseBody
    public String getUser(@PathVariable Integer id) {

        int s = adminService.getCheck(id);
        return "数量" + s;

    }

    @RequestMapping(value = "getcheck.do", method = RequestMethod.GET)
    public String getCheck(int id) {

        int s = adminService.getCheck(id);
        System.out.print(s);
        return "ss";
    }


}
